package com.java1412.controller;

import com.alibaba.fastjson.JSONObject;
import com.java1412.entity.User;
import com.java1412.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author fengge
 * @create 2020-11-01 11:48
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "list",produces =  {"application/json;charset=UTF-8"})
    @ResponseBody
    public String list() {
        List<User> userList = userService.findAll();
        return JSONObject.toJSONString(userList);
    }
}
